/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MasterSupplier.java
 *
 * Created on Aug 9, 2010, 9:39:41 PM
 */
package com.ivanbiz.gui;

import com.ivanbiz.helper.CenterRenderer;
import com.ivanbiz.dao.CustomerDAO;
import com.ivanbiz.helper.ServiceHelper;
import com.ivanbiz.impl.CustomerDAOImpl;
import com.ivanbiz.model.Customer;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Aprisma
 */
public class MasterCustomer extends javax.swing.JInternalFrame {

    ServiceHelper serviceHelper = new ServiceHelper();
    CustomerDAO customerDAO = new CustomerDAOImpl();
    List<Customer> listCustomer = new ArrayList<Customer>();

    /** Creates new form MasterSupplier */
    public MasterCustomer() {
        initComponents();
        updateData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        paneCustomer = new javax.swing.JPanel();
        labelKode = new javax.swing.JLabel();
        labelNama = new javax.swing.JLabel();
        labelAlamat = new javax.swing.JLabel();
        labelTelepon = new javax.swing.JLabel();
        textKode = new javax.swing.JTextField();
        textNama = new javax.swing.JTextField();
        textAlamat = new javax.swing.JTextField();
        textTelepon = new javax.swing.JTextField();
        panelTombol = new javax.swing.JPanel();
        buttonSimpan = new javax.swing.JButton();
        buttonUbah = new javax.swing.JButton();
        buttonHapus = new javax.swing.JButton();
        Reset = new javax.swing.JButton();
        panelCari = new javax.swing.JPanel();
        textCariCustomer = new javax.swing.JTextField();
        comboCari = new javax.swing.JComboBox();
        panelDaftarCustomer = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableCustomer = new javax.swing.JTable();

        setBorder(new org.jdesktop.swingx.border.DropShadowBorder());
        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("Master Pelanggan");

        paneCustomer.setBorder(javax.swing.BorderFactory.createTitledBorder("Pelanggan"));

        labelKode.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelKode.setText("Kode");

        labelNama.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelNama.setText("Nama");

        labelAlamat.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelAlamat.setText("Alamat");

        labelTelepon.setFont(new java.awt.Font("Tahoma", 1, 11));
        labelTelepon.setText("Telepon");

        textKode.setFont(new java.awt.Font("Tahoma", 1, 11));

        textNama.setFont(new java.awt.Font("Tahoma", 1, 11));

        textAlamat.setFont(new java.awt.Font("Tahoma", 1, 11));

        textTelepon.setFont(new java.awt.Font("Tahoma", 1, 11));

        javax.swing.GroupLayout paneCustomerLayout = new javax.swing.GroupLayout(paneCustomer);
        paneCustomer.setLayout(paneCustomerLayout);
        paneCustomerLayout.setHorizontalGroup(
            paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneCustomerLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelTelepon)
                    .addComponent(labelNama)
                    .addComponent(labelKode)
                    .addComponent(labelAlamat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(textAlamat, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE)
                    .addComponent(textNama, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE)
                    .addComponent(textKode, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE)
                    .addComponent(textTelepon, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE))
                .addContainerGap())
        );
        paneCustomerLayout.setVerticalGroup(
            paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneCustomerLayout.createSequentialGroup()
                .addGroup(paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textKode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelKode))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textNama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelNama))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textAlamat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelAlamat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paneCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textTelepon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelTelepon))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        panelTombol.setBorder(javax.swing.BorderFactory.createTitledBorder("Tombol"));

        buttonSimpan.setFont(new java.awt.Font("Tahoma", 1, 11));
        buttonSimpan.setText("Simpan");
        buttonSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSimpanActionPerformed(evt);
            }
        });

        buttonUbah.setFont(new java.awt.Font("Tahoma", 1, 11));
        buttonUbah.setText("Ubah");
        buttonUbah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonUbahActionPerformed(evt);
            }
        });

        buttonHapus.setFont(new java.awt.Font("Tahoma", 1, 11));
        buttonHapus.setText("Hapus");
        buttonHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonHapusActionPerformed(evt);
            }
        });

        Reset.setFont(new java.awt.Font("Tahoma", 1, 11));
        Reset.setText("Reset");
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelTombolLayout = new javax.swing.GroupLayout(panelTombol);
        panelTombol.setLayout(panelTombolLayout);
        panelTombolLayout.setHorizontalGroup(
            panelTombolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTombolLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelTombolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonSimpan, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
                    .addComponent(buttonUbah, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
                    .addComponent(buttonHapus, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
                    .addComponent(Reset, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelTombolLayout.setVerticalGroup(
            panelTombolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTombolLayout.createSequentialGroup()
                .addComponent(buttonSimpan)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(buttonUbah)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonHapus)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Reset)
                .addGap(13, 13, 13))
        );

        panelCari.setBorder(javax.swing.BorderFactory.createTitledBorder("Cari Pelanggan"));

        textCariCustomer.setFont(new java.awt.Font("Tahoma", 1, 11));
        textCariCustomer.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textCariCustomerKeyReleased(evt);
            }
        });

        comboCari.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        comboCari.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout panelCariLayout = new javax.swing.GroupLayout(panelCari);
        panelCari.setLayout(panelCariLayout);
        panelCariLayout.setHorizontalGroup(
            panelCariLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCariLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboCari, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textCariCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelCariLayout.setVerticalGroup(
            panelCariLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCariLayout.createSequentialGroup()
                .addGroup(panelCariLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textCariCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboCari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelDaftarCustomer.setBorder(javax.swing.BorderFactory.createTitledBorder("Daftar Pelanggan"));

        tableCustomer.setAutoCreateRowSorter(true);
        tableCustomer.setFont(new java.awt.Font("Tahoma", 1, 11));
        tableCustomer.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableCustomer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableCustomerMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tableCustomer);

        javax.swing.GroupLayout panelDaftarCustomerLayout = new javax.swing.GroupLayout(panelDaftarCustomer);
        panelDaftarCustomer.setLayout(panelDaftarCustomerLayout);
        panelDaftarCustomerLayout.setHorizontalGroup(
            panelDaftarCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDaftarCustomerLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 742, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelDaftarCustomerLayout.setVerticalGroup(
            panelDaftarCustomerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDaftarCustomerLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(panelCari, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelDaftarCustomer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(paneCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panelTombol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(paneCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelTombol, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelCari, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelDaftarCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-800)/2, (screenSize.height-550)/2, 800, 550);
    }// </editor-fold>//GEN-END:initComponents

    private void buttonHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonHapusActionPerformed
        try {
            Customer customer = (Customer) listCustomer.get(tableCustomer.getSelectedRow());
            customerDAO.delete(customer);
            updateData();
        } catch (Exception ex) {
            Logger.getLogger(MasterCustomer.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonHapusActionPerformed

    private void buttonSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSimpanActionPerformed
        try {
            if (textKode.getText().equals("") || textNama.getText().equals("") || textAlamat.getText().equals("") || textTelepon.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "Data Belum Lengkap !!!");
            } else {
                Customer customers = (Customer) customerDAO.getDataByEqual(Customer.class, "kode", textKode.getText().toUpperCase());
                if (customers != null) {
                    JOptionPane.showMessageDialog(null, "Kode Sudah Ada !!!");
                } else {
                    Customer customer = new Customer();
                    customer.setKode(textKode.getText().toUpperCase());
                    customer.setNama(textNama.getText().toUpperCase());
                    customer.setAlamat(textAlamat.getText().toUpperCase());
                    customer.setTelp(textTelepon.getText().toUpperCase());
                    customer.setCreateDate(new Date());
                    customerDAO.save(customer);
                    updateData();
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(MasterCustomer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buttonSimpanActionPerformed

    private void buttonUbahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUbahActionPerformed
        try {
            if (textKode.getText().equals("") || textNama.getText().equals("") || textAlamat.getText().equals("") || textTelepon.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "Data Belum Lengkap !!!");
            } else {
                Customer customer = (Customer) listCustomer.get(tableCustomer.getSelectedRow());
                customer.setKode(textKode.getText().toUpperCase());
                customer.setNama(textNama.getText().toUpperCase());
                customer.setAlamat(textAlamat.getText().toUpperCase());
                customer.setTelp(textTelepon.getText().toUpperCase());
                customer.setUpdateDate(new Date());
                customerDAO.update(customer);
                updateData();
            }
        } catch (Exception ex) {
            Logger.getLogger(MasterCustomer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buttonUbahActionPerformed

    private void tableCustomerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableCustomerMouseClicked
        textKode.setEditable(false);
        buttonSimpan.setEnabled(false);
        buttonHapus.setEnabled(true);
        buttonUbah.setEnabled(true);
        Customer customer = (Customer) listCustomer.get(tableCustomer.getSelectedRow());
        textKode.setText(customer.getKode());
        textNama.setText(customer.getNama());
        textAlamat.setText(customer.getAlamat());
        textTelepon.setText(customer.getTelp());
    }//GEN-LAST:event_tableCustomerMouseClicked

    private void textCariCustomerKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textCariCustomerKeyReleased
        try {
            listCustomer = customerDAO.getDataByLike(Customer.class, comboCari.getSelectedItem().toString(), textCariCustomer.getText());
            updateTableCustomer();
        } catch (Exception ex) {
            Logger.getLogger(MasterCustomer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_textCariCustomerKeyReleased

    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetActionPerformed
        updateData();
    }//GEN-LAST:event_ResetActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Reset;
    private javax.swing.JButton buttonHapus;
    private javax.swing.JButton buttonSimpan;
    private javax.swing.JButton buttonUbah;
    private javax.swing.JComboBox comboCari;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel labelAlamat;
    private javax.swing.JLabel labelKode;
    private javax.swing.JLabel labelNama;
    private javax.swing.JLabel labelTelepon;
    private javax.swing.JPanel paneCustomer;
    private javax.swing.JPanel panelCari;
    private javax.swing.JPanel panelDaftarCustomer;
    private javax.swing.JPanel panelTombol;
    private javax.swing.JTable tableCustomer;
    private javax.swing.JTextField textAlamat;
    private javax.swing.JTextField textCariCustomer;
    private javax.swing.JTextField textKode;
    private javax.swing.JTextField textNama;
    private javax.swing.JTextField textTelepon;
    // End of variables declaration//GEN-END:variables

    private void updateComboCari() {
        Object[] dataClass = serviceHelper.getPropertyClass(Customer.class);
        Object[] dataSearch = new Object[2];
        dataSearch[0] = dataClass[1];
        dataSearch[1] = dataClass[2];
        comboCari.setModel(new DefaultComboBoxModel(dataSearch));
    }
    // End of variables declaration

    private void updateData() {
        try {
            buttonHapus.setEnabled(false);
            buttonUbah.setEnabled(false);
            buttonSimpan.setEnabled(true);
            textKode.setEditable(true);
            textKode.setText("");
            textNama.setText("");
            textAlamat.setText("");
            textTelepon.setText("");
            listCustomer = customerDAO.getAll(Customer.class);
            updateTableCustomer();
            updateComboCari();
        } catch (Exception ex) {
            Logger.getLogger(MasterCustomer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void updateTableCustomer() {
        String[] judul = {"No", "Kode", "Nama", "Alamat", "Telp"};
        Object[][] isi = new Object[listCustomer.size()][5];
        int x = 0;
        int no = 0;
        for (Customer customer : listCustomer) {
            no += 1;
            isi[x][0] = no;
            isi[x][1] = customer.getKode();
            isi[x][2] = customer.getNama();
            isi[x][3] = customer.getAlamat();
            isi[x][4] = customer.getTelp();
            x++;
        }
        tableCustomer.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
            }
        });
        TableColumn column = tableCustomer.getColumnModel().getColumn(0);
        column.setPreferredWidth(75);
        column.setMaxWidth(75);
        column.setCellRenderer(new CenterRenderer());
        TableColumn column1 = tableCustomer.getColumnModel().getColumn(1);
        column1.setPreferredWidth(100);
        column1.setMaxWidth(100);
        column1.setCellRenderer(new CenterRenderer());
        TableColumn column2 = tableCustomer.getColumnModel().getColumn(2);
        column2.setPreferredWidth(275);
        column2.setMaxWidth(275);
        TableColumn column4 = tableCustomer.getColumnModel().getColumn(4);
        column4.setPreferredWidth(140);
        column4.setMaxWidth(140);
        column4.setCellRenderer(new CenterRenderer());
    }
}
